package com.fjxd.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fjxd.order.pojo.Order;
import com.fjxd.order.pojo.vo.OrderVo;
import com.fjxd.order.pojo.vo.TicketVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author csw
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    /**
     * 通过订单id查询订单
     * @param id 订单id
     * @return 返回一个订单对象
     */
    @Select("select * from tb_order where id = #{id}")
    List<Order> getOrderById(Integer id);

    List<Order> getOrderByUserId(Integer id);

    boolean updateOrderStatusById(Integer id,Integer status);

    @Select("select op.id, op.people_id as peopleId,order_id from tb_order as o join tb_ordermanypeople  as op on o.id = op.order_id where order_id=#{orderId}")
    List<OrderVo> getOrderManyPeople(Integer orderId);

    @Select("select t.id,t.store_id,t.order_id,t.ticket_id from tb_order o join tb_ordermanyticket t on o.id = t.order_id where order_id=#{orderId}")
    List<TicketVo> getOrderManyTicket(Integer orderId);

    Integer insertorderVo(Integer peopleId, Integer orderId);

    void insertticketVo(Integer orderId, String tId, String ticketStoreId);

    boolean deleteByPeople(Integer id);

    boolean deleteByTicket(Integer id);

    boolean deleteOrder(Integer id);
}
